<template>
  <div>
    <div style="text-align: center;padding-bottom: 10px">
      <span v-if="data.length !== total">
        正在{{actionName}}第
        <span style="color: red">{{data.length+1}}</span>条数据
      </span>
      <span v-else>{{actionName}}完成</span>
      ，总数：
      <span style="color: red">{{total}}</span>，成功：
      <span style="color: red">{{success}}</span>，失败：
      <span style="color: red">{{error}}</span>
    </div>
    <el-table :data="data">
      <el-table-column type="index" width="55" align="center" />
      <el-table-column label="房间号" align="center" prop="roomNo" />
      <el-table-column v-if="data[0] && data[0].meterNo" label="电表号" align="center" prop="meterNo" />
      <el-table-column label="操作状态" align="center" prop="status">
        <template slot-scope="scope">
          <span v-if="scope.row.status == 0" style="color: green">成功</span>
          <span v-if="scope.row.status == 1 || scope.row.status == -1" style="color: red">失败</span>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  props: {
    data: {},
    total: {},
    actionName: {}
  },
  computed: {
    success() {
      return this.data?.filter(item => item.status == 0).length || 0;
    },
    error() {
      return this.data?.filter(item => item.status == 1).length || 0;
    }
  }
};
</script>